home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Engineering Notes / Embedding / Embedding an OpenDoc File < prev    next >
Encoding:
Text File  |  1996-08-16  |  3.4 KB  |  81 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                     
  5. Embedding an OpenDoc File
  6. ODF Release 1                                                                                                                                                             
  7.  
  8.  
  9. Table of Contents
  10. ----------------------
  11. • Insert Menu Command
  12. • Embedding an OpenDoc Document
  13.  
  14.  
  15. Insert Menu Command
  16.  
  17. The user chooses the Insert command from the Document menu to select a document (or stationery) and embed it as a part within your part.
  18.  
  19. In order for your part to respond to the Insert menu command it should:
  20.     
  21. - Create a subclass of FW_CInsertCommand. Like any commands involving embedded frames this command must be undoable.
  22.  
  23. - Override FW_CEmbeddingFrame::NewInsertCommand and return an instance of your subclass of FW_CInsertCommand.
  24.  
  25. - Implement SingleEmbeddedFrameInternalized in the subclass of FW_CContent maintained by your selection object.
  26.  
  27. In response to the Insert menu command, by default ODF opens a file-access dialog box displaying all available OpenDoc documents and stationeries .  The filtering is done by installing a file filter proc which tests that the file's creator is 'odtm'. You can change this behavior by overriding FW_CEmbeddingFrame::DoInsert and providing your own FW_COpenFileParameters  parameter to FW_CChooseFile::ChooseFileToOpen.
  28.  
  29. All ODF samples supporting embedding (ODFDraw, ODFContainer, ODFEmbed, ODFTable) currently support the Insert Menu Command.
  30.  
  31.  
  32. Embedding an OpenDoc Document
  33.  
  34. In the case where your part editor needs to embed another OpenDoc document or stationery without intervention by the user, ODF provides the function FW_ClonePartFromFile.  This function located in FWEmdUtl.cpp allows you to clone a part from another document or stationery. Your code should look something like:
  35.  
  36. void CMyFrame::EmbedOpenDocFile(Environment* ev, const FW_PFileSpecification& fileSpec)
  37. {
  38.      // Call FW_ClonePartFromFile
  39.         FW_CAcquiredODPart embeddedPart = FW_ClonePartFromFile(ev, this, fileSpec);
  40.         
  41.         // Create the proxy
  42.         CMyProxy* proxy = FW_NEW(CMyProxy, (ev, .....));    
  43.         
  44.   // Create the frame shape
  45.         FW_CRect tempRect(FW_kFixed0, FW_kFixed0, FW_IntToFixed(100),  FW_IntToFixed(100));
  46.         FW_CAcquiredODShape aqFrameShape = ::FW_NewODShape(ev, tempRect);
  47.  
  48.         // Call FW_CPresentation Embed
  49.         FW_TRY
  50.         {
  51.              GetPresentation(ev)->Embed(ev, 
  52.                                                                                                                                       embeddedPart,
  53.                                                                                                                                       NULL,
  54.                                                                                                                                    kODFrameObject,
  55.                                                                                                                                    proxy,
  56.                                                                                                                              aqFrameShape,
  57.                                                                                                                              FW_CPart::gViewAsFrameToken,
  58.                                                                                                                              NULL,
  59.                                                                                                                              0,
  60.                                                                                                                              FALSE,
  61.                                                                                                                              FALSE);
  62.         }
  63.         FW_CATCH_BEGIN
  64.         FW_CATCH_EVERYTHING () 
  65.         {
  66.             delete proxy;
  67.             FW_THROW_SAME ();
  68.         }
  69.         FW_CATCH_END
  70.         
  71.         // At this point you can add the proxy object to your content
  72.      ....
  73.         
  74.   // Don't forget also to clip the embedded facets
  75.         FW_CFacetClipper facetClipper(ev, fMyPart);
  76.         facetClipper.Clip(ev, GetPresentation(ev), aqFrameShape);
  77. }
  78.  
  79.  
  80. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  81. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.